package com.vcg.kafka;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * Created by wuyu on 2016/9/20.
 */
@SpringBootTest(classes = KafkaApplication.class)
@RunWith(SpringRunner.class)
public class HelloWorld {

    @Autowired
    KafkaTemplate<Integer, String> kafkaTemplate;

    @Test
    public void testSend() throws InterruptedException {
        JSONObject json = new JSONObject();
        json.put("msg", "hello");
        kafkaTemplate.send("test", 0, json.toString());
        Thread.sleep(1000);
    }
}
